home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / shots / BomberABomb.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  2.8 KB  |  99 lines

  1. class classes.shots.BomberABomb
  2. {
  3.    var x;
  4.    var y;
  5.    var id;
  6.    var dir;
  7.    var clip;
  8.    var xMov;
  9.    var yMov;
  10.    var cMax;
  11.    var xDiv;
  12.    var yDiv;
  13.    var c = 0;
  14.    var power = 50;
  15.    var yank = false;
  16.    var Name = "bomberABomb";
  17.    function BomberABomb(px, py, pxMov, pdir, pid)
  18.    {
  19.       this.x = px;
  20.       this.y = py;
  21.       this.id = pid;
  22.       this.dir = pdir;
  23.       _root.d = _root.d + 1;
  24.       this.clip = _root.attachMovie("bomberABomb","bomberABomb" + this.id + "Clip",_root.d + 3600);
  25.       this.clip._x = this.x;
  26.       this.clip._y = this.y;
  27.       this.xMov = pxMov;
  28.       this.yMov = this.dir != "U" ? 6 : -6;
  29.       this.cMax = _root.randRange(30,60);
  30.       this.xDiv = _root.randRange2(0.99,0.97);
  31.       this.yDiv = _root.randRange2(0.99,0.97);
  32.    }
  33.    function hit()
  34.    {
  35.       this.explo();
  36.       this.yank = true;
  37.    }
  38.    function bombed()
  39.    {
  40.       this.explo();
  41.       this.yank = true;
  42.    }
  43.    function explo()
  44.    {
  45.       _root.createExploB([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(90,120),100,"B"]);
  46.       var _loc3_ = 0;
  47.       var _loc4_ = random(2) + 3;
  48.       while(_loc3_ < _loc4_)
  49.       {
  50.          _root.createExploB([this.x + this.clip._width / 2 + _root.randRange(-25,25),this.y + this.clip._height / 2 + _root.randRange(-25,25),_root.randRange(40,75),_root.randRange(25,60),"B"]);
  51.          _loc3_ = _loc3_ + 1;
  52.       }
  53.    }
  54.    function main()
  55.    {
  56.       this.c = this.c + 1;
  57.       this.xMov *= this.xDiv;
  58.       this.yMov *= this.yDiv;
  59.       if(this.c >= this.cMax)
  60.       {
  61.          this.explo();
  62.          this.yank = true;
  63.       }
  64.       if(this.clip.hitTest(_root[_root.char + "Clip"]))
  65.       {
  66.          this.explo();
  67.          _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
  68.          this.yank = true;
  69.       }
  70.       var _loc4_ = 0;
  71.       var _loc6_ = _root.broShots.length;
  72.       while(_loc4_ < _loc6_)
  73.       {
  74.          var _loc5_ = _root.broShots[_loc4_] + "Clip";
  75.          if(this.clip.hitTest(_root[_loc5_]))
  76.          {
  77.             this.explo();
  78.             this.yank = true;
  79.             _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar;
  80.             var _loc3_ = _root.broShots[_loc4_];
  81.             _root[_loc3_].exploX = this.x + this.clip._width / 2;
  82.             _root[_loc3_].exploY = this.y + this.clip._height / 2;
  83.             _root[_loc3_].hit(20);
  84.          }
  85.          _loc4_ = _loc4_ + 1;
  86.       }
  87.       this.x += this.xMov;
  88.       this.y += this.yMov;
  89.       this.clip._x = this.x;
  90.       this.clip._y = this.y;
  91.       if(this.yank)
  92.       {
  93.          _root.audio.playLevel4("bomberBombX" + (random(3) + 1),_root.randRange(13,22));
  94.          _root.removeEnemyShot("bomberABomb" + this.id);
  95.          this.yank = false;
  96.       }
  97.    }
  98. }
  99.